package fr.hoteia.appengine.archetype.server.dao.impl;

import javax.persistence.EntityManager;
import javax.persistence.EntityTransaction;

import fr.hoteia.appengine.archetype.server.service.Manager;

/**
 * Base class for Business Services - use this class for utility methods and
 * generic CRUD methods.
 * 
 * <p><a href="BaseManager.java.html"><i>View Source</i></a></p>
 *
 * @author Denis GOSSET <a href="http://www.hoteia.com"><i>Hoteia.com</i></a>
 * 
 */
public class BaseDao implements Manager {
	
	private EntityManager em;
	
    public EntityManager getEntityManager() {
    	if(em == null){
    		em = EMF.get().createEntityManager();
    	}
    	return em;
    }

    public EntityTransaction getTransaction() {
    	EntityTransaction tx = getEntityManager().getTransaction();
    	return tx;
    }
    
    public void close() {
//    	getEntityManager().close();
    }
}
